* @return FileRepoStatus object.
*/
function delete( $reason, $suppress = false ) {
- global $wgUseSquid;
if ( $this->getRepo()->getReadOnlyReason() !== false ) {
return $this->readOnlyFatalStatus();
}
DeferredUpdates::addUpdate( SiteStatsUpdate::factory( array( 'images' => -1 ) ) );
}
- $this->purgeEverything();
- foreach ( $archiveNames as $archiveName ) {
- $this->purgeOldThumbnails( $archiveName );
- }
+ // Hack: the lock()/unlock() pair is nested in a transaction so the locking is not
+ // tied to BEGIN/COMMIT. To avoid slow purges in the transaction, move them outside.
+ $file = $this;
+ $this->getRepo()->getMasterDB()->onTransactionIdle(
+ function() use ( $file, $archiveNames ) {
+ global $wgUseSquid;
- if ( $wgUseSquid ) {
- // Purge the squid
- $purgeUrls = array();
- foreach ($archiveNames as $archiveName ) {
- $purgeUrls[] = $this->getArchiveUrl( $archiveName );
+ $file->purgeEverything();
+ foreach ( $archiveNames as $archiveName ) {
+ $file->purgeOldThumbnails( $archiveName );
+ }
+
+ if ( $wgUseSquid ) {
+ // Purge the squid
+ $purgeUrls = array();
+ foreach ( $archiveNames as $archiveName ) {
+ $purgeUrls[] = $file->getArchiveUrl( $archiveName );
+ }
+ SquidUpdate::purge( $purgeUrls );
+ }
}
- SquidUpdate::purge( $purgeUrls );
- }
+ );
return $status;
}